<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>出库管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body>
<br/>
	<form:form id="inputForm" modelAttribute="outOrder"   method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<form:hidden path="act.taskId"/>
		<form:hidden path="act.taskName"/>
		<form:hidden path="act.taskDefKey"/>
		<form:hidden path="act.procInsId"/>
		<form:hidden path="act.procDefId"/>
		<form:hidden id="flag" path="act.flag"/>
		<div class="control-group">
			<label class="control-label">日期：</label>
			<div class="controls">
				<input name="cdate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${outOrder.cdate}" pattern="yyyy-MM-dd HH:mm:ss"/>" />
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">批次号：</label>
			<div class="controls">
				<form:input path="batch" htmlEscape="false" readonly="true"  maxlength="20" class="input-xlarge "/>
			</div>
		</div>


		<div class="control-group">
			<label class="control-label">客户名称：</label>
			<div class="controls">
				<form:input path="xname" htmlEscape="false"  readonly="true"  maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">出库人：</label>
			<div class="controls">
				<form:input path="user.name" htmlEscape="false"  readonly="true"  maxlength="100" class="input-xlarge "/>

			</div>
		</div>
		<div class="control-group">
			<label class="control-label">目的地：</label>
			<div class="controls">
				<form:input path="destination" readonly="true" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">收件人电话：</label>
			<div class="controls">
				<form:input path="ctel" readonly="true"  htmlEscape="false" maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">接收人名称：</label>
			<div class="controls">
				<form:input path="cname" readonly="true"  htmlEscape="false" maxlength="100" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">电话：</label>
			<div class="controls">
				<form:input path="tel" readonly="true"  htmlEscape="false" maxlength="50" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">地址：</label>
			<div class="controls">
				<form:input path="adress" readonly="true"   htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
			<div class="control-group">
				<label class="control-label">出库明细：</label>
				<div class="controls">
					<table id="contentTable" class="table table-striped table-bordered table-condensed">
						<thead>
							<tr>
								<th class="hide"></th>
								<th>货物名</th>
								<th>计划数量</th>
								<th>库位</th>
							</tr>
						</thead>
						<tbody id="outOrderDetailList">
						<c:forEach var="row" items="${outOrder.outOrderDetailList}" varStatus="idx">
							<tr  >
								<td class="hide">
									<input   name="outOrderDetailList[${idx.index}].id" type="hidden" value="${row.id}"/>
									<input   name="outOrderDetailList[${idx.index}].cid.id" type="hidden" value="${row.cid.id}"/>

									<input   name="outOrderDetailList[${idx.index}].woods.id" type="hidden" value="${row.woods.id}"/>
									<input id="outOrderDetailList${idx.index}_delFlag" name="outOrderDetailList[${idx.index}].delFlag" type="hidden" value="0"/>
								</td>
								<td>
									<input  name="outOrderDetailList[${idx.index}].woods.name" readonly type="text" value="${row.woods.name}" maxlength="11" class="input-small "/>


								</td>

								<td>
									<input id="outOrderDetailList${idx.index}_plannumber" name="outOrderDetailList[${idx.index}].plannumber" readonly type="text" value="${row.plannumber}" maxlength="11" class="input-small "/>
								</td>
								<td>
									<input  name="outOrderDetailList[${idx.index}].cid.name" readonly type="text" value="${row.cid.name}" maxlength="11" class="input-small "/>



								</td>



							</tr>
						</c:forEach>
						</tbody>

					</table>



				</div>
			</div>

		<div class="form-actions">

			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
		<c:if test="${not empty outOrder.id}">
			<act:histoicFlow procInsId="${outOrder.act.procInsId}" />
		</c:if>
	</form:form>
</body>
</html>